package com.zjitc.Redis.TheNewRedis;

import org.springframework.beans.factory.annotation.Autowired;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

/**
 * Create by IntelliJ IDEA
 *
 * @author: jsonor
 * @date-Time: 2018/4/12 14:44
 * @description:
 */
public class RedisSecond implements redisCommand{

  @Autowired
  private JedisPool pool;

  @Autowired
  public RedisSecond(JedisPool pool){
    this.pool = pool;
  }

  @Override
  public void set(String key, String value) {
    Jedis jedis = null;
    try {
      jedis = pool.getResource();
      jedis.set(key,value);
    }finally {
      if (jedis != null){
        jedis.close();
      }
    }
  }
}
